#ifndef RM_FAKE_SERIAL_DRIVER__RM_FAKE_SERIAL_DRIVER_HPP_
#define RM_FAKE_SERIAL_DRIVER__RM_FAKE_SERIAL_DRIVER_HPP_

#include <tf2_ros/buffer.h>
#include <tf2_ros/transform_broadcaster.h>
#include <tf2_ros/transform_listener.h>

#include <auto_aim_interfaces/msg/target.hpp>
#include <geometry_msgs/msg/transform_stamped.hpp>
#include <geometry_msgs/msg/twist.hpp>
#include <rclcpp/publisher.hpp>
#include <rclcpp/rclcpp.hpp>
#include <rclcpp/subscription.hpp>
#include <serial_driver/serial_driver.hpp>
#include <std_msgs/msg/float64.hpp>
#include <std_srvs/srv/trigger.hpp>
#include <visualization_msgs/msg/marker.hpp>

// C++ system

#include <future>
#include <memory>
#include <string>
#include <thread>
#include <vector>
// 从vision_interfaces加载消息类型
#include "vision_interfaces/msg/robot.hpp"

namespace rm_fake_serial_driver
{
class FakeSerialDriverNode : public rclcpp::Node
{
public:
  explicit FakeSerialDriverNode(const rclcpp::NodeOptions & options);

  ~FakeSerialDriverNode() override;

private:
  void publishOdomToGimbalTransform();
  void getParams();
  void setParam(const rclcpp::Parameter & param);
  void timerTask();
  //void publishRobotMessage();
  void resetTracker();

  // Param client to set detect_colr
  //using ResultFuturePtr = std::shared_future<std::vector<rcl_interfaces::msg::SetParametersResult>>;
  //bool initial_set_param_ = false;
  //rclcpp::AsyncParametersClient::SharedPtr detector_param_client_;
  // Service client to reset tracker
  rclcpp::Client<std_srvs::srv::Trigger>::SharedPtr reset_tracker_client_;
  //ResultFuturePtr set_param_future_;

  // 定时发布tf相关变量
  //double timestamp_offset_;
  std::unique_ptr<tf2_ros::TransformBroadcaster> tf_broadcaster_;
  rclcpp::TimerBase::SharedPtr timer_;
  std::future<void> timer_future_;

  // For vision attacker
  rclcpp::Publisher<vision_interfaces::msg::Robot>::SharedPtr robot_pub_;
  vision_interfaces::msg::Robot robot_msg;
  // For debug usage
  rclcpp::Publisher<std_msgs::msg::Float64>::SharedPtr latency_pub_;
  rclcpp::Publisher<visualization_msgs::msg::Marker>::SharedPtr marker_pub_;
};
}  // namespace rm_fake_serial_driver

#endif  // RM_FAKE_SERIAL_DRIVER__RM_FAKE_SERIAL_DRIVER_HPP_
